package com.liuyk.commonlib;

import android.app.Application;
import android.content.Context;

import com.liuyk.commonlib.help.InitHelp;
import com.liuyk.commonlib.manager.ImageLoaderManager;
import com.liuyk.commonlib.utility.ThreadPoolUtils;

/**
 * common初始化
 * <p>
 * Created by liuyakui on 2020/5/3.
 */
public class App extends Application {
    public static Context context;

    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();
        InitHelp.initRouter(this);
    }

    @Override
    public void onTrimMemory(int level) {
        super.onTrimMemory(level);
        ImageLoaderManager.trimMemory(context, level);
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        ThreadPoolUtils.getInstance().executor(() -> {
            //子线程执行，以防出现卡顿
            ImageLoaderManager.clearDiskMemory(context);
        });
    }
}
